<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>代码修饰器</title>
    <link rel="stylesheet" type="text/css" href="https://www.layuicdn.com/layui/css/layui.css" />
    <script src="https://www.layuicdn.com/layui/layui.js"></script>
</head>
<body>
    <pre class="layui-code">
        public ListNode mergeKLists (ListNode[] lists) {
            // write code here
            ListNode res = new ListNode(0);
            int len = lists.length;
            if (len == 0 || lists == null) {
                return res;
            }
            ListNode pre = res;
            for (int i = 0; i < len-1; i+=2) {
                ListNode l1 = lists[i];
                ListNode l2 = lists[i+1];
                while (l1 != null && l2 != null) {
                    if (l1.value <= l2.value) {
                        pre.next = l1;
                        l1 = l1.next;
                    } else {
                        pre.next = l2;
                        l2 = l2.next;
                    }
                    pre = pre.next;
                }
                while (l1 != null) {
                    pre.next = l1;
                    pre = pre.next;
                    l1 = l1.next;
                }
                while (l2 != null) {
                    pre.next = l2;
                    pre = pre.next;
                    l2 = l2.next;
                }
            }
            return res.next;
        }
    </pre>

    <script>
        layui.use("code", function () {
            layui.code({
                title: "三链表排序",       // 标题
                about: false,             // 是否剔除右上关于
                skin: "notepad"           // 皮肤风格
            });
        })
    </script>
</body>
</html>